﻿using Ay.Framework.WPF.Controls;
using System.Windows;
using System.Windows.Input;

namespace AllinpayEleMe.Widget
{
    /// <summary>
    /// AlertDialog.xaml 的交互逻辑
    /// </summary>
    public partial class AlertDialog : AyWindow
    {

        public delegate bool OkEventHandle();

        private OkEventHandle ok;
        private bool canDragMove = false;

        private AlertDialog()
        {
            InitializeComponent();
        }

        public static AlertDialog NewInstance()
        {
            return new AlertDialog();
        }

        public AlertDialog SetInfo(string info)
        {
            this.info.Text = info;
            return this;
        }

        public AlertDialog SetPositiveButton(string content, OkEventHandle ok)
        {
            this.ok = ok;
            btn_ok.Content = content;

            return this;
        }

        public AlertDialog AddDragMove()
        {
            canDragMove = true;
            return this;
        }

        public new void Show()
        {
            this.ShowDialog();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            //Hide();
            if (ok == null || ok())
            {
                this.Close();
            }
        }

        private void AyWindow_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (canDragMove)
            {
                try
                {
                    DragMove();
                }
                catch { }
            }
        }
    }
}
